package com.liufh.controller;

import com.liufh.service.ProviderServiceFeignClient;
import com.liufh.service.ResumeServiceFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 此微服务为 Feign学习
 *
 * @author: liufh
 * @create: 2022-01-13 17:12
 */
@RestController
@RequestMapping("/autodeliver")
public class AutodeliverController {

    @Autowired
    private ResumeServiceFeignClient resumeServiceFeignClient;

    @Autowired
    private ProviderServiceFeignClient providerServiceFeignClient;

    @GetMapping("/checkState/{userId}")
    public Integer findResumeOpenState(@PathVariable Long userId) {
        Integer defaultResumeState = resumeServiceFeignClient.findDefaultResumeState(userId);
        return defaultResumeState + 10000;
    }

    /**
     * 测试：消费者、提供者 返回值不同的情况
     */
    @GetMapping("/test01/{userId}")
    public String test01(@PathVariable Long userId) {
        Integer defaultResumeState = resumeServiceFeignClient.findDefaultResumeState(userId);
        Integer res = defaultResumeState + 10000;
        return res + "";
    }

    /**
     * 测试：调用两个提供者微服务
     */
    @GetMapping("/test02/{userId}")
    public String test02(@PathVariable Long userId) {
        Integer defaultResumeState = resumeServiceFeignClient.findDefaultResumeState(userId);
        String providerStr = providerServiceFeignClient.providerTest();
        String res = defaultResumeState + providerStr;
        return res;
    }

}
